<?php

namespace Application\pform\t_test;

use Application\model\BaseOrderModel;

/**
 * @property string $platform 平台
 * @property string $channel 渠道子包ID
 * @property string $openId 平台用户ID
 * @property string $sid 游戏服务器ID
 * @property string $actorId 游戏角色ID
 * @property string $actorName 游戏角色名
 * @property string $shopId 商品ID
 * @property string $level 玩家角色等级
 * @property string $vipLevel  玩家角色VIP等级
 * @property string $ext  透传参数
 * @property string $ext2  透传参数
 */
class OrderModel extends BaseOrderModel
{
    protected $auto_set_map = [
        'cpid' => 'channel',
        'ccid' => 'channel',
        'account' => 'openId',
        'amount' => 'money',
        'vip' => 'vipLevel',
    ];

    /**
     *
     * @return void
     */
    protected function initPayParams()
    {
    }

    public function getRetunData($config){
        $cpid = $this->get('channel');
        $sid = $this->get('sid');
        $openId = $this->get('openId');
        $actorId = $this->get('actorId');
        $actorName = $this->get('actorName');
        $shopId = $this->get('shopId');
        $orderId = $this->orderId;

        $data = [
            'platform' => PFORM_NAME,
            'sid' => $sid,
            'openid' => $openId,
            'cpid' => $cpid,
            'role_id' => $actorId,
            'role_name' => $actorName,
            'amount' => $config['amount'],
            'level' => $this->get('level'),
            'vip' => $this->get('vipLevel'),
            'ext' => $shopId.'|'.$orderId.'|'. $this->get('ext'),
            'time' => time(),
        ];

        $param = http_build_query($data);
        $url = 'http://mrgd-loginpay-version.hzmyue-2.cn/api/payment?';
//        $res = curl($url. $param);
        return [
            'orderId' => $this->orderId,
            'payNotifyUrl' => PAY_NOTIFY_URL,
            'rate' => RADIO,
            'goodsId' => $config['id'],
            'goodsName' => $config['describe'],
            'money' => $config['amount'],
            'ext' => $this->get('ext')
        ];
    }
}